package la.bbs558.controller.user;

import cn.dev33.satoken.annotation.SaIgnore;
import la.bbs558.controller.base.Result;
import la.bbs558.entity.params.PostSearchPage;
import la.bbs558.entity.params.UserSearchPage;
import la.bbs558.service.SearchService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author: Shanks
 * @date: 2023/12/16 22:19
 * @desc:
 */
@RestController
@RequestMapping("search")
@RequiredArgsConstructor
public class SearchController {

    private final SearchService searchService;

    @GetMapping("post") 
    @SaIgnore
    public Result<?> searchPost(PostSearchPage searchPage) {
        searchService.searchPost(searchPage);
        return Result.success(searchPage);
    }

    // TODO 暂时不做
    @GetMapping("user")
    public Result<?> searchUser(@RequestBody UserSearchPage searchPage) {
        searchService.searchUser(searchPage);
        return Result.success(searchPage);
    }

    @GetMapping("hot")
    @SaIgnore
    public Result<?> hotList() {
        return Result.success(searchService.searchHotList());
    }

    @GetMapping("history")
    public Result<?> history() {
        return Result.success(searchService.searchHistoryList());
    }

    @PostMapping("clearHistory")
    public Result<?> clearHistory() {
        searchService.clearHistory();
        return Result.success();
    }
}
